package com.xiaohui.gwc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiaohui.gwc.mode.Products;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: Poppin
 * @Date: 2021/11/30 12:32
 * @Version: 1.0
 */
public interface ProductsMapper extends BaseMapper<Products> {

    @Select("SELECT products.pid, products.pname,products.price,products.pic,products.author,products.press,products.pubdate FROM category,products WHERE category.cid = products.category_id AND category.cname =#{cname}")
    List<Products> getCategory(String cname);

    @Select("SELECT p.pid ,p.pname ,p.price ,p.pic ,p.author ,p.press ,p.pubdate FROM rd r left join products p on r.prodid = p.pid ORDER BY r.rdsl DESC limit 0,5")
    List<Products> getRd();
}
